﻿@using MvcFileUploader.HtmlHelper
@using MvcFileUploader.Models
@{
    //option for inline view only
    var ui = "jquery".Equals(Request.Params["ui"]) ? UploadUI.JQueryUI : UploadUI.Bootstrap;
    var toggleUi = ui == UploadUI.Bootstrap ? "jquery" : "bootstrap";
}
<div class="modal-content" style="overflow-x: auto;">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title text-primary">@SAIM.Resources.Site.Files</h4>
    </div>
    <div class="modal-body table-responsive">

        <div id="error-message" class="alert alert-danger fade in hidden">
            <a href="#" class="close close-alert" data-dismiss="alert" aria-label="close">&times;</a>
            Archivo no eliminado
        </div>

        <div class="panel panel-default">
            <div class="table-responsive">
                <table id="grid-data" class="table table-striped">
                    <thead>
                        <tr>
                            <th data-column-id="Options" data-formatter="link">Opciones</th>
                            <th data-column-id="FileName">Archivo</th>
                            <th data-column-id="FileSize">Tamaño</th>
                            <th data-column-id="UserName">Usuario</th>
                            <th data-column-id="CreationDate">Fecha de modificación</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>


        <div class="well">
            <legend>Adjuntar archivos</legend>
            <p class="help-block">Formatos permitidos: gif, jpg, jpeg, tiff, png, pdf, doc, docx, xls, xlsx, xml, txt</p>
            @(
                Html.MvcFileUpload()
                .UploadAt(Url.Action("UploadFile"))
                .UIStyle(ui)
                .WithFileTypes(@"/(\.|\/)(gif|jpe?g|tiff|png|pdf|docx?|xlsx?|xml|txt)$/i")
                .WithMaxFileSize(10000000)
                .AddFormField("listId", ViewBag.ListId)
                .AddFormField("columnId", ViewBag.ColumnId)
                .DisableImagePreview()
                .RenderInline("_MvcFileupload")
            )

        </div>
    </div>
</div>
<div class="modal fade" id="modalFileEditions" role="dialog"></div>

<script type="text/javascript">
    listId = '@ViewBag.ListId';
    columnId = '@ViewBag.ColumnId';
    urlEditions = '@Url.Action("_GetFileEditions", "EVirtual")';
    urlFiles = '@Url.Action("GetListAttachments", "EVirtual")/?listId=@ViewBag.ListId&columnId=@ViewBag.ColumnId';
    function getColumn(column, row) {
        var components = '<div style="float: left; padding: 4px 4px 4px 5px;" title="Eliminar archivo">' +
                                '<button type="button" class="btn btn-xs btn-danger remove-file" data-mask=\"'+ row.Mask + '\">' +
                                    '<span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button></div>';

        components += '<div style="float: left; padding: 4px 4px 4px 5px;" title="Descargar"><a href=\"' + '@Url.Action("GetAttachedFile", "EVirtual")/?listId=@ViewBag.ListId&attachmentId=' + row.Mask + '" role="button" class="btn btn-xs btn-primary">' +
                     '<span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span></a></div>';

        if (row.HasEditions) {
            components += '<div style="float: left; padding: 4px 4px 4px 5px;" title="Historial de ediciones">' +
                                '<button type="button" class="CommentHistory btn btn-xs btn-primary" data-filename="' + row.FileName + '">' +
                                    '<span class="glyphicon glyphicon-time" aria-hidden="true"></span></button></div>';
        }
        return components;
    }
</script>
<script type="text/javascript" src="@Url.Content("~/Scripts/EVirtual/UploadFile.js")"></script>


